package org.work;
import java.sql.*;
import org.model.Xsb;
public class DBConn {
	Connection conn;
	PreparedStatement pstmt;
	public DBConn(){
		try{
			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
			conn=DriverManager.getConnection("jdbc:sqlserver://localhost:1433;"+"databaseName=XSCJ","liuyan","123456");
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}
	
	public boolean save(Xsb xs){
		try{
			pstmt=conn.prepareStatement("insert into XSB values(?,?,?,?,?,?)");
			pstmt.setString(1, xs.getXh());
			pstmt.setString(2, xs.getXm());
			pstmt.setByte(3, xs.getXb());
			pstmt.setString(4, xs.getZy());
			pstmt.setDate(5, xs.getCssj());
			pstmt.setString(6, xs.getBz());
			pstmt.executeUpdate();
			return true;
		}catch(Exception e){
			e.printStackTrace();
			return false;
		}
	}
}
